package com.yyg.controller;

        import com.alibaba.fastjson.JSON;
        import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
        import com.yyg.entity.EasyUser;
        import com.yyg.service.EasyUserService;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.web.bind.annotation.CrossOrigin;
        import org.springframework.web.bind.annotation.RequestBody;
        import org.springframework.web.bind.annotation.RequestMapping;
        import org.springframework.web.bind.annotation.RestController;

        import java.util.HashMap;
        import java.util.List;


@CrossOrigin("http://localhost:8081")
@RestController
public class LoginController {
    @Autowired
    private EasyUserService easyUserService;
    @RequestMapping("/login")
    //@requeBody是指，这是要接受的的类,接收前端传递过来的类
   public String login(@RequestBody EasyUser user){
        String flag="error";
        HashMap<String,Object> res=new HashMap<>();
        EasyUser user1= easyUserService.CheckLogin(user);
        System.out.println("user1"+user1);
        if (user1!=null){
            flag="ok";
        }
        System.out.println("flag"+flag);
        res.put("flag",flag);
        res.put("user",user);
        String res_json = JSON.toJSONString(res);
        System.out.println("res_json"+res_json);
        return res_json;
   }
}
